<?php

use think\migration\Migrator;
use think\migration\db\Column;

class DeliverCar extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('deliver_car',['comment' => '车辆'])
            ->addColumn('company_id', 'integer', ['limit' => 10, 'after' => 'id', 'default' => 0, 'comment' => '公司ID'])
            ->addColumn('no', 'string', ['limit' => 20, 'after' => 'company_id', 'default' => '', 'comment' => '车牌号'])
            ->addColumn('type', 'integer', ['limit' => 2, 'after' => 'no', 'default' => 1, 'comment' => '车辆类型 1:小面,2:中面,3:微面,4:小货,5:中货,6:大货,7:冷藏车,8:私家车'])
            ->addColumn('length', 'integer', ['limit' => 2, 'after' => 'type', 'default' => 0, 'comment' => '车长 1:4米2,2:5米2,3:6米8,4:7米6,5:9米6,6:13米,7:其他'])
            ->addColumn('color', 'string', ['limit' => 20, 'after' => 'length', 'default' => '', 'comment' => '车辆颜色'])
            ->addColumn('passenger_num', 'integer', ['limit' => 2, 'after' => 'color', 'default' => 0, 'comment' => '载客数'])
            ->addColumn('load_weight', 'integer', ['limit' => 2, 'after' => 'passenger_num', 'default' => 0, 'comment' => '载重'])
            ->addColumn('volume', 'integer', ['limit' => 2, 'after' => 'load_weight', 'default' => 0, 'comment' => '体积'])
            ->addColumn('brand', 'string', ['limit' => 20, 'after' => 'volume', 'default' => '', 'comment' => '品牌'])
            ->addColumn('img', 'string', ['limit' => 2000, 'after' => 'brand', 'default' => '', 'comment' => '车辆图片'])
            ->addColumn('remark', 'text', ['after' => 'img', 'comment' => '备注'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'after' => 'remark', 'comment' => '1:正常,2:禁用'])
            ->addColumn('create_time', 'integer', ['limit' => 10, 'after' => 'status', 'default' => 0, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit' => 10, 'after' => 'create_time', 'default' => 0, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit' => 10, 'after' => 'update_time', 'default' => 0, 'comment' => '删除时间'])
            ->create();
    }
}
